
import type { App, Component } from 'vue'
import 'view-ui-plus/dist/styles/viewuiplus.css'

import {
  Input,
  Button,
  Modal,
  Tabs,
  TabPane,
  Form,
  FormItem,
  Select,
  Option,
  Exception,
  Radio,
  RadioGroup,
  Checkbox,
  CheckboxGroup,
  InputNumber,
  Switch,
  Row,
  Col,
  Tooltip,
  DatePicker,
  TimePicker,
  Dropdown,
  DropdownMenu,
  DropdownItem,
  Message
} from 'view-ui-plus'

const components: Record<string, Component> = {
  eInput: Input,
  eButton: Button,
  eModal: Modal,
  eTabs: Tabs,
  eTabPane: TabPane,
  eForm: Form,
  eFormItem: FormItem,
  eSelect: Select,
  eOption: Option,
  eException: Exception,
  eRadio: Radio,
  eRadioGroup: RadioGroup,
  eCheckbox: Checkbox,
  eCheckboxGroup: CheckboxGroup,
  eInputNumber: InputNumber,
  eSwitch: Switch,
  eRow: Row,
  eCol: Col,
  eTooltip: Tooltip,
  eDatePicker: DatePicker,
  eTimePicker: TimePicker,
  eDropdown: Dropdown,
  eDropdownMenu: DropdownMenu,
  eDropdownItem: DropdownItem
}

const methods: Record<string, Component> = {
  $Message: Message
}
export default function setupView(app: App) {
  Object.keys(components).forEach(key => {
    app.component(key, components[key])
  })
  Object.keys(methods).forEach(key => {
    app.config.globalProperties[key] = methods[key]
  })
}